"""
哈希算法（摘要）- MD5 / SHA1 / SHA256 - hashlib
"""
import hashlib

hasher = hashlib.md5('hello'.encode())
print(hasher.hexdigest())

hasher = hashlib.md5()
with open('Python-3.7.1.tar.xz', 'rb') as file:
    file_iter = iter(lambda: file.read(4096), b'')
    for data in file_iter:
        hasher.update(data)
    # data = file.read(512)
    # while data:
    #     hasher.update(data)
    #     data = file.read(512)
print(hasher.hexdigest())
